<?php
/**
 * admin service file Created by PhpStorm.
 * User: yang
 * Date: 2020/04/26
 */

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PublicController extends Controller
{
    /**
     * 检测表字段数据的唯一性
     * @param Request $request
     * @return mixed
     */
    public function checkOnly(Request $request)
    {
        $data = $request->only(['table', 'id', 'key', 'val']);

        return \Common\Service\PublicService::checkOnly($data);
    }

    /**上传文件
     * @param Request $request
     * @return array
     */
    public function uploadFile(Request $request)
    {
        $data = $request->only(['type']);

        return \Common\Service\UploadFileService::ossUpload($_FILES["file"], $data['type']);
    }

    /**
     * 删除OSS上的文件
     * @param Request $request
     * @return array
     */
    public function deleteFile(Request $request)
    {
        $data = $request->only(['url']);

        return \Common\Service\UploadFileService::ossDelete($data['url']);
    }

}